package com.lvcoding.spring5aop.annotation;

import lombok.SneakyThrows;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author wuyanshen
 * @discription 切面类
 * @date 2021-03-09 下午2:30
 */
@Component
@Aspect
public class MyAspect {

    @Pointcut("execution(* com.lvcoding.spring5aop.service.*.*(..))")
    public void pointcut() {

    }

    @SneakyThrows
    @Around("pointcut()")
    public Object around(ProceedingJoinPoint joinPoint) {

        System.out.println("aop(注解) 我在方法前做了操作----");
        Object obj = joinPoint.proceed();
        System.out.println("aop(注解) 我在方法后做了操作----");
        return obj;

    }
}
